#define  _CRT_SECURE_NO_WARNINGS


#include<stdio.h>
#include<string.h>


int main()
{
    int t = 0;
    scanf("%d", &t);
    while (t--)
    {
        char arr[10][21] = { 0 }, temp[21] = { 0 };
        int n = 0, i = 0, j = 0;
        scanf("%d", &n);
        getchar();
        for (i = 0; i < n; i++)
        {
            scanf("%s", arr[i]);
        }
        for (i = 0; i < n; i++)
        {
            for (j = i + 1; j < n; j++)
            {
                if (strcmp(arr[i], arr[j]) > 0)
                {
                    strcpy(temp, arr[i]);
                    strcpy(arr[i], arr[j]);
                    strcpy(arr[j], temp);
                }
            }
        }
        for (i = 0; i < n; i++)
            puts(arr[i]);
    }

    return 0;
}